<script setup lang="ts">
const { waterForm, tableHeaders } = defineProps<{
  waterForm: Object; // 定义采样时间的类型
  tableHeaders: Array; // 定义采样时间的类型
  tabler: Array; // 定义采样时间的类型
}>();
</script>

<template>
  <div>
    <div
      v-for="(pageData, pageIndex) in tableHeaders"
      :key="pageIndex"
      style="padding: 0 30px"
    >
      <h1 style="text-align: center; padding-top: 40px">
        土壤 气相色谱质谱法分析原始记录（A面）
      </h1>
      <div>SXLPHJ/JL/CX-22-87</div>
      <table class="table">
        <tr>
          <td colspan="1">任务编号</td>
          <td colspan="7">
            {{ waterForm.task_name }}
          </td>
          <td colspan="1">采样日期</td>
          <td colspan="8">
            {{ waterForm.sampling_time }}
          </td>
        </tr>
        <tr>
          <td colspan="1">分析方法</td>
          <td colspan="7">
            {{ waterForm.method }}
          </td>
          <td colspan="1">分析日期</td>
          <td colspan="8">
            {{ waterForm.anal_time }}
          </td>
        </tr>
        <tr>
          <td colspan="1">环境温度</td>
          <td colspan="6" style="width: 7%">{{ waterForm.temperature }}℃</td>
          <td colspan="1">环境湿度</td>
          <td colspan="9">{{ waterForm.humidity }}℃</td>
        </tr>
        <tr>
          <td colspan="1">分析仪器</td>
          <td colspan="5" style="width: 7%">
            {{ waterForm.device.device_name }}
          </td>
          <td colspan="1">仪器型号</td>
          <td colspan="1">
            {{ waterForm.device.device_model }}
          </td>
          <td colspan="1">仪器编号</td>
          <td colspan="8">
            {{ waterForm.device.device_number }}
          </td>
        </tr>

        <tr>
          <td colspan="1" rowspan="3">测定条件</td>
          <td colspan="16" style="width: 7%">
            {{ waterForm.bdatas.cdtj.cd_1 }}
          </td>
        </tr>
        <tr>
          <td colspan="16" style="width: 7%">
            {{ waterForm.bdatas.cdtj.cd_2 }}
          </td>
        </tr>
        <tr>
          <td colspan="16" style="width: 7%">
            {{ waterForm.bdatas.cdtj.cd_3 }}
          </td>
        </tr>
        <tr>
          <td colspan="1">计算公式</td>
          <td colspan="7">
            {{ waterForm.js_formula }}
          </td>
          <td colspan="1">试样定容体积Vx（mL）</td>
          <td colspan="5">
            {{ waterForm.sydrtj }}
          </td>
        </tr>
      </table>
      <table class="table">
        <tr>
          <td v-for="(key, value) in tabler" :key="value">{{ key }}</td>
        </tr>
        <tr v-for="(row, rowIndex) in pageData" :key="rowIndex">
          <td v-for="(key, colIndex) in Object.keys(row)" :key="colIndex">
            {{ row[key] }}
          </td>
        </tr>
      </table>

      <div
        style="
          display: flex;
          align-items: center;
          justify-content: space-between;
          margin-top: 20px;
        "
      >
        <div>分析人：</div>
        <div>校核人：</div>
        <div>审核人：</div>
        <div>第 {{ pageIndex + 1 }} 页 / 共 {{ tableHeaders.length }} 页</div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 设置表格的边框、外边距等 */
table {
  border-collapse: collapse;
  width: 100%;
}

table th,
table td {
  border: 1px solid #ddd;
  padding: 2px 10px;
  font-size: 11px;
  text-align: center;
  height: 20px;
}

tr {
  page-break-inside: avoid;
}

.fs12 {
  font-size: 12px;
}

.table {
  width: 100%;
}

/* 打印时隐藏所有默认的头部和尾部 */
@media print {
  /* 隐藏页眉和页脚 */
  @page {
    margin: 0;
  }

  table {
    page-break-inside: avoid;
  }

  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  th,
  td {
    page-break-inside: avoid;
  }

  body {
    margin: 0;
    padding: 0;
    zoom: 100%;
  }

  div {
    page-break-inside: avoid;
  }

  /* 禁用打印页脚和页眉 */
  .no-print {
    display: none;
  }

  /* 如果你不想打印特定元素，可以这样设置 */
  header,
  footer,
  nav,
  .no-print {
    display: none !important;
  }

  /* 保证内容区域不受其他元素影响 */
  .content {
    display: block;
  }
}
</style>
